//
//  SPReviewCell.m
//  Sport
//
//  Created by Cass on 2018/1/30.
//  Copyright © 2018年 Cass. All rights reserved.
//

#import "SPReviewCell.h"
#import "YYLabel.h"
#import "YYText.h"
#import "SPComment.h"
#import "SPCommentFrame.h"
@interface SPReviewCell ()

/** 文本内容 */
@property (nonatomic , weak) YYLabel *contentLabel;

@end

@implementation SPReviewCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString *ID = @"cell";
    SPReviewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
//        cell = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([SPReviewCell class]) owner:nil options:nil].lastObject;
        cell = [[self alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self _setup];
        [self _setupSubViews];
    }
    return self;
}

- (void)setCommentFrame:(SPCommentFrame *)commentFrame{
    _commentFrame = commentFrame;
    SPComment *comment = commentFrame.comment;
    
    self.contentLabel.frame = commentFrame.textFrame;
    self.contentLabel.attributedText = comment.attributedText;
}
- (void)_setup{
    //设置颜色
    self.backgroundColor = [UIColor whiteColor];
    self.contentView.backgroundColor = [UIColor whiteColor];
}

- (void)_setupSubViews{
    //文本
    YYLabel *contentLabel = [[YYLabel alloc]init];
    contentLabel.numberOfLines = 0;
    contentLabel.textAlignment = NSTextAlignmentLeft;
    [self addSubview:contentLabel];
    self.contentLabel = contentLabel;
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

- (void)layoutSubviews{
    [super layoutSubviews];
}
@end
